home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / warpwarp.c < prev    next >
C/C++ Source or Header  |  1999-11-17  |  4KB  |  159 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13.  
  14. unsigned char *warpwarp_bulletsram;
  15.  
  16.  
  17.  
  18. /***************************************************************************
  19.  
  20.   Convert the color PROMs into a more useable format.
  21.  
  22.   Warp Warp doesn't use PROMs - the 8-bit code is directly converted into a
  23.   color.
  24.  
  25.   The color RAM is connected to the RGB output this way (I think - schematics
  26.   are fuzzy):
  27.  
  28.   bit 7 -- 300 ohm resistor  -- BLUE
  29.         -- 820 ohm resistor  -- BLUE
  30.         -- 300 ohm resistor  -- GREEN
  31.         -- 820 ohm resistor  -- GREEN
  32.         -- 1.6kohm resistor  -- GREEN
  33.         -- 300 ohm resistor  -- RED
  34.         -- 820 ohm resistor  -- RED
  35.   bit 0 -- 1.6kohm resistor  -- RED
  36.  
  37.   Moreover, the bullet is pure white, obtained with three 220 ohm resistors.
  38.  
  39. ***************************************************************************/
  40. void warpwarp_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  41. {
  42.     int i;
  43.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  44.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  45.  
  46.  
  47.     for (i = 0;i < Machine->drv->total_colors;i++)
  48.     {
  49.         int bit0,bit1,bit2;
  50.  
  51.  
  52.         /* red component */
  53.         bit0 = (i >> 0) & 0x01;
  54.         bit1 = (i >> 1) & 0x01;
  55.         bit2 = (i >> 2) & 0x01;
  56.         *(palette++) = 0x1f * bit0 + 0x3c * bit1 + 0xa4 * bit2;
  57.         /* green component */
  58.         bit0 = (i >> 3) & 0x01;
  59.         bit1 = (i >> 4) & 0x01;
  60.         bit2 = (i >> 5) & 0x01;
  61.         *(palette++) = 0x1f * bit0 + 0x3c * bit1 + 0xa4 * bit2;
  62.         /* blue component */
  63.         bit0 = 0;
  64.         bit1 = (i >> 6) & 0x01;
  65.         bit2 = (i >> 7) & 0x01;
  66.         *(palette++) = 0x1f * bit0 + 0x3c * bit1 + 0xa4 * bit2;
  67.     }
  68.  
  69.     for (i = 0;i < TOTAL_COLORS(0);i += 2)
  70.     {
  71.         COLOR(0,i) = 0;            /* black background */
  72.         COLOR(0,i + 1) = i / 2;    /* colored foreground */
  73.     }
  74. }
  75.  
  76.  
  77.  
  78. /***************************************************************************
  79.  
  80.   Draw the game screen in the given osd_bitmap.
  81.   Do NOT call osd_update_display() from this function, it will be called by
  82.   the main emulation engine.
  83.  
  84. ***************************************************************************/
  85. void warpwarp_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  86. {
  87.     int offs;
  88.  
  89.  
  90.     /* for every character in the Video RAM, check if it has been modified */
  91.     /* since last time and update it accordingly. */
  92.     for (offs = videoram_size - 1;offs >= 0;offs--)
  93.     {
  94.         if (dirtybuffer[offs])
  95.         {
  96.             int mx,my,sx,sy;
  97.  
  98.             mx = offs % 32;
  99.             my = offs / 32;
  100.  
  101.             if (my == 0)
  102.             {
  103.                 sx = 33;
  104.                 sy = mx;
  105.             }
  106.             else if (my == 1)
  107.             {
  108.                 sx = 0;
  109.                 sy = mx;
  110.             }
  111.             else
  112.             {
  113.                 sx = mx + 1;
  114.                 sy = my;
  115.             }
  116.  
  117.             drawgfx(tmpbitmap,Machine->gfx[0],
  118.                     videoram[offs],
  119.                     colorram[offs],
  120.                     0,0,
  121.                     8*sx,8*sy,
  122.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  123.  
  124.             dirtybuffer[offs] = 0;
  125.         }
  126.     }
  127.  
  128.  
  129.     /* copy the character mapped graphics */
  130.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  131.  
  132.  
  133.     if (warpwarp_bulletsram[0] > 1)
  134.     {
  135.         int x,y;
  136.  
  137.  
  138.         x = 260 - warpwarp_bulletsram[0];
  139.         y = 252 - warpwarp_bulletsram[1];
  140.         if (x >= Machine->drv->visible_area.min_x && x+3 <= Machine->drv->visible_area.max_x &&
  141.             y >= Machine->drv->visible_area.min_y && y+3 <= Machine->drv->visible_area.max_y)
  142.         {
  143.             int colour;
  144.             int i,j;
  145.  
  146.  
  147.             colour = Machine->pens[0xf6];    /* white */
  148.  
  149.             for (i = 0;i < 4;i++)
  150.             {
  151.                 for (j = 0;j < 4;j++)
  152.                 {
  153.                     plot_pixel(bitmap, x+j, y+i, colour);
  154.                 }
  155.             }
  156.         }
  157.     }
  158. }
  159.